var t, a, e, s = require("../../../@babel/runtime/helpers/interopRequireDefault"), o = require("../../../@babel/runtime/helpers/interopRequireWildcard"), i = require("../../../@babel/runtime/helpers/objectSpread2"), r = require("../../../@babel/runtime/helpers/toConsumableArray"), d = s(require("../../../@babel/runtime/regenerator")), n = require("../../../@babel/runtime/helpers/asyncToGenerator"), c = require("../../../@babel/runtime/helpers/defineProperty"), l = o(require("../../../utils/watch.js")), g = getApp(), h = [], _ = "", p = 1, u = require("../../../mybehaviors/location/location"), m = {
    home: "goods.category.category-home",
    children: "goods.category.get-children-category",
    goods: "goods.category.get-goods-list-by-category-id"
};

Page({
    behaviors: [ u ],
    data: (t = {
        current_goods_key: "shop",
        language: "",
        brandShow: "",
        categoryShow: "",
        active: 9999,
        active2: !0,
        allLoaded: !1,
        topStatus: "",
        err: !0,
        turl: "/category",
        arg: {
            index: 10,
            item: "pinch"
        },
        onelist: [],
        contentlist: {},
        cartInfo: {},
        list: [],
        goodsInfo: {},
        carts: [],
        cartIDs: [],
        specid: "",
        goodsCarts: [],
        goodsCartsTotal: [],
        activeName: "",
        secondaryId: "",
        threeId: "",
        threeInfo: [],
        show2: !1,
        showTitle: "",
        titleInfo: {},
        foodInfo: [],
        show: !0,
        globalParameter: {},
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        activatId: "",
        LoadMoreTest: "",
        isGetCart: !0,
        ADImg: "",
        ADUrl: "",
        small_cat_adv_url: null,
        isRecommend: !0,
        showCate: !1,
        state: {},
        scrollTop: null,
        flxShow: !1,
        category_template: "01",
        lastItem: "",
        lastIndex: "",
        parent_id: null,
        isCategoryMore: !1,
        isCategory_total_page: 0,
        isCategoryPage: 1,
        popPrice: "",
        integral: "积分",
        main_category_page: 1,
        main_category_total: 0,
        isSelfPickCategory: !1,
        deliverId: null,
        point: {},
        isMultiSpecs: !1,
        specsVIPPrc: null,
        template_no: !0,
        fiveShow: !1,
        showGoodScreen: !1,
        searchScreen: {}
    }, c(t, "scrollTop", 0), c(t, "category_template_four_set", []), c(t, "tiktok_list", []), 
    c(t, "tiktok_details", {
        search_type: 0,
        order_type: 0,
        cate_id: ""
    }), t),
    onLoad: (e = n(d.default.mark(function t(e) {
        var s, o, i, r, n;
        return d.default.wrap(function(t) {
            for (;;) switch (t.prev = t.next) {
              case 0:
                if (console.log(e), e.mid && g._setMid(e.mid), !e.tmpl || "dy" != e.tmpl) {
                    t.next = 8;
                    break;
                }
                return this.data.isSelfPickCategory = !0, t.next = 6, this.getNowPackageDeliver();

              case 6:
                t.next = 9;
                break;

              case 8:
                a = m;

              case 9:
                try {
                    (s = wx.getStorageSync("zoneId")) && this.setData({
                        zoneId: s
                    });
                } catch (t) {}
                l.setWatcher(this), wx.showLoading({
                    title: "加载中",
                    mask: !0
                }), (o = wx.getStorageSync("yz_basic_info")) && (r = null === (i = o.lang) || void 0 === i ? void 0 : i.goods, 
                n = r && r.vip_price ? r.vip_price : "会员价", this.setData({
                    vip_price_txt: n,
                    globalParameter: o.globalParameter
                })), this.data.isGetCart = !1, this.data.lastItem ? this.tabsaData(this.data.lastIndex, this.data.lastItem) : this.getCategoryNew();

              case 16:
              case "end":
                return t.stop();
            }
        }, t, this);
    })), function(t) {
        return e.apply(this, arguments);
    }),
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        }), wx.setNavigationBarTitle({
            title: this.data.language["分类"]
        });
        var a = wx.getStorageSync("integral");
        a && this.setData({
            integral: a
        });
    },
    onShow: function() {
        this.data.deliverId && this.getNowPackageDeliver(), wx.showShareMenu({
            withShareTicket: !1,
            menus: [ "shareAppMessage", "shareTimeline" ]
        }), !this.data.isGetCart || "01" != this.data.category_template && "04" != this.data.category_template && "05" != this.data.category_template ? this.data.isGetCart = !0 : this.updateData();
        var t = wx.getStorageSync("yz_basic_info");
        1 == t.home.item.is_decorate && "category04" == t.home.item.ViewSet.category.name && this.getCategorySet();
    },
    getCategorySet: function() {
        var t = this;
        g._getNetWork({
            url: g.getNetAddresss("plugin.decorate.frotend.category-template-four-set.index"),
            success: function(a) {
                var e = a.data, s = e.result, o = e.msg, i = e.data;
                if (0 == s) return g.tips(o);
                t.setData({
                    category_template_four_set: i
                });
            }
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.setData({
            flxShow: !1
        });
    },
    onReachBottom: function() {},
    onShareTimeline: function() {
        var t = wx.getStorageSync("yz_uid"), a = "";
        return t && (a = t), {
            title: this.data.title,
            query: "mid=".concat(a)
        };
    },
    onShareAppMessage: function() {
        var t = wx.getStorageSync("yz_uid"), a = "";
        return t && (a = t), {
            path: "/packageG/pages/category_v2/category_v2?mid=" + a
        };
    },
    onPageScroll: function(t) {
        0 == t.scrollTop && this.setData({
            flxShow: !1
        });
    },
    watch: {
        activeName: function(t) {
            if ("" != t.length) this.setData({
                showTitle: []
            }); else {
                var a = this.data.titleInfo;
                this.setData({
                    showTitle: a
                });
            }
        }
    },
    getMoreCategoryNew: function() {
        var t = this, e = this.data;
        if (!(e.main_category_page >= e.main_category_total)) {
            console.log("加载更多主分类"), this.data.main_category_page++;
            var s = g.getNetAddresss(a.home), o = wx.getStorageSync("yz_basic_info"), i = "";
            1 == o.home.item.is_decorate && "category04" == o.home.item.ViewSet.category.name && "tiktok" == this.data.current_goods_key && (s = g.getNetAddresss("plugin.tiktok-cps.api.goods.good-cate"), 
            i = "04");
            var r = {
                page: this.data.main_category_page
            };
            g._getNetWork({
                url: s,
                data: r,
                success: function(a) {
                    var e = a.data, s = [];
                    s = "04" == i ? e.data.data : e.data.category.data, t.setData({
                        onelist: t.data.onelist.concat(s)
                    });
                }
            });
        }
    },
    bindscrolltolower: function(t) {
        this.data.isLoadMore ? this.getMoreData() : (console.log("没有更多数据"), wx.showToast({
            title: "没有更多数据",
            icon: "none"
        }));
    },
    bindscrolltolower02: function(t) {
        this.data.isLoadMore ? this.getMoreData02(1) : (console.log("没有更多数据"), wx.showToast({
            title: "没有更多数据",
            icon: "none"
        }));
    },
    upper: function(t) {
        this.setData({
            flxShow: !1
        });
    },
    changeScroll: function(t) {
        this.data.scrollTop = t.detail.scrollTop, t.detail.scrollTop > 180 && !g._isTextEmpty(this.data.ADUrl) || g._isTextEmpty(this.data.ADUrl) && t.detail.scrollTop > 10 ? this.setData({
            flxShow: !0
        }) : t.detail.scrollTop < 10 && this.setData({
            flxShow: !1
        });
    },
    clickActive: function(t) {
        var a = t.target.dataset.item || t.currentTarget.dataset.item;
        if (this.data.isRecommend || this.setData({
            ADImg: a.adv_img,
            ADUrl: a.small_adv_url
        }), this.setData({
            secondaryId: a.id
        }), g._isTextEmpty(a.has_many_children)) this.setData({
            threeInfo: [],
            activatId: a.id
        }), this.getData(a.id); else {
            var e = [ {
                name: "全部",
                id: a.id
            } ], s = "05" != this.data.category_template ? [].concat(e, r(a.has_many_children)) : r(a.has_many_children);
            this.setData({
                threeInfo: s,
                threeId: a.id,
                activatId: a.id
            }), console.log(this.data.threeInfo, "sssssss左侧点击二级的时候"), this.data.threeInfo.length > 0 && "05" == this.data.category_template ? (this.setData({
                threeId: this.data.threeInfo[0].id
            }), this.getData(this.data.threeInfo[0].id)) : this.getData(a.id);
        }
    },
    tabsa: function(t) {
        var a = t.currentTarget.dataset.index, e = t.currentTarget.dataset.item;
        this.data.lastIndex == a ? this.data.fiveShow = !this.data.fiveShow : this.data.fiveShow = !0, 
        this.tabsaData(a, e), this.setData({
            lastIndex: a,
            lastItem: e,
            fiveShow: this.data.fiveShow
        });
    },
    bpfun: function() {
        wx.navigateTo({
            url: "/packageB/member/category/brand_v2/brand_v2"
        });
    },
    allList: function() {
        this.setData({
            active2: !0,
            active: 9999
        }), this.getCategoryNew("allList");
    },
    tabsaData: function(t, a) {
        if (console.log(t, a, "sssssss"), "tiktok" == this.data.current_goods_key) return this.setData({
            active2: !1,
            active: t,
            "tiktok_details.cate_id": a.cate_id,
            page: 1,
            flxShow: !0,
            scrollTop: 0
        }), void this.getTikTokGoods();
        this.setData({
            "state.adv_img": a.adv_img,
            "state.adv_url": a.small_adv_url
        }), this.setData({
            active: t,
            active2: !1,
            parent_id: a.id
        }), this.getContentlist(a.id), "01" != this.data.category_template && "04" != this.data.category_template && "03" != this.data.category_template || this.getData(a.id);
    },
    clickADTo: function() {
        if (this.data.active2) try {
            wx.navigateTo({
                url: this.data.small_cat_adv_url
            });
        } catch (t) {
            console.log(t);
        } else try {
            wx.navigateTo({
                url: this.data.ADUrl
            });
        } catch (t) {
            console.log(t);
        }
    },
    getContentlist: function(t) {
        var e = this, s = g.getNetAddresss(a.children);
        console.log("activeApi.children222"), s += "&parent_id=" + t, s += "&as_id=" + this.data.zoneId, 
        g._getNetWork({
            url: s,
            success: function(t) {
                var a = t.data;
                if (1 == a.result) {
                    if (e.setData({
                        isLoadMore: !0,
                        page: 1
                    }), e.setData({
                        isRecommend: !1
                    }), e.setData({
                        err: !1
                    }), "01" == e.data.category_template || "03" == e.data.category_template || "04" == e.data.category_template || "05" == e.data.category_template) {
                        a.data.goods_list.last_page ? e.setData({
                            total_page: a.data.goods_list.last_page
                        }) : e.setData({
                            total_page: 0
                        }), e.setData({
                            "contentlist.recommend": a.data.data,
                            "contentlist.set": a.data.set,
                            "contentlist.member_cart": e.data.cartInfo
                        }), a.data.goods_list.data || e.setData({
                            foodInfo: []
                        }), console.log(e.data.contentlist);
                        var s = e.data.contentlist;
                        e.setData({
                            list: s
                        }), console.log(e.data.list, "activeApi.list"), e.setData({
                            ADImg: e.data.state.adv_img,
                            ADUrl: e.data.state.adv_url,
                            isCategory_total_page: a.data.last_page,
                            isCategoryPage: 1,
                            isCategoryMore: a.data.last_page > 1
                        }), e.setCatagory(e.data.contentlist);
                    } else {
                        a.data.last_page ? e.setData({
                            total_page: a.data.last_page
                        }) : e.setData({
                            total_page: 0
                        });
                        var o = a.data;
                        o.tjfl = !1, o.set = a.data.set, e.setData({
                            contentlist_one: o,
                            list: o
                        });
                    }
                    e.data.page < e.data.total_page ? e.setData({
                        LoadMoreTest: "加载更多"
                    }) : e.setData({
                        LoadMoreTest: "没有更多"
                    });
                } else e.setData({
                    err: !0
                }), console.log(a.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    onChangeGoods: function(t) {
        var a = this, e = t.currentTarget.dataset.name;
        this.setData({
            current_goods_key: e
        }), "tiktok" == e ? g._getNetWork({
            url: g.getNetAddresss("plugin.tiktok-cps.api.goods.good-cate"),
            success: function(t) {
                var e = t.data, s = e.result, o = e.msg, i = e.data;
                if (0 == s) return g.tips(o);
                a.setData({
                    onelist: i.data,
                    main_category_total: i.last_page,
                    main_category_page: i.current_page,
                    active: 0,
                    "tiktok_details.cate_id": i.data[0].cate_id
                }), a.getTikTokGoods();
            }
        }) : this.getCategoryNew();
    },
    getTikTokGoods: function() {
        var t = this;
        g._getNetWork({
            url: g.getNetAddresss("plugin.tiktok-cps.api.goods.good-list"),
            data: i(i({}, this.data.tiktok_details), {}, {
                page: this.data.page
            }),
            success: function(a) {
                var e = a.data, s = e.result, o = e.msg, i = e.data;
                if (0 == s) return g.tips(o);
                1 == Number(i.current_page) ? t.setData({
                    tiktok_list: i.products
                }) : t.setData({
                    tiktok_list: t.data.tiktok_list.concat(i.products)
                }), t.setData({
                    page: Number(i.current_page),
                    total_page: Number(i.last_page)
                });
            }
        });
    },
    onChange: function(t) {
        this.setData({
            activeName: t.detail
        });
    },
    getCategoryNew: function() {
        var t = this, e = g.getNetAddresss(a.home), s = {
            as_id: this.data.zoneId
        };
        g._getNetWork({
            url: e,
            data: s,
            success: function(a) {
                console.log("模板中心---", a);
                var e = a.data, s = "01";
                if (1 == e.result) {
                    s = e.data.category_template ? e.data.category_template.names : "01", t.setData({
                        main_category_total: e.data.category.last_page
                    }), e.data.set.web_design_enable && t.getwebdesImg();
                    var o = wx.getStorageSync("yz_basic_info");
                    if (o && 1 === o.home.item.is_decorate && !t.data.isSelfPickCategory && (s = 0 != o.home.item.ViewSet.category.is_default ? o.home.item.ViewSet.category.code.substring(8) : "01"), 
                    wx.hideLoading(), t.setData({
                        showCate: !0,
                        onelist: e.data.category.data,
                        err: !1,
                        isRecommend: !0,
                        category_template: s
                    }), "01" == t.data.category_template || "03" == t.data.category_template || "04" == t.data.category_template || "05" == t.data.category_template) e.data.goods_list.last_page ? t.setData({
                        total_page: e.data.goods_list.last_page
                    }) : t.setData({
                        total_page: 0
                    }), t.data.page < t.data.total_page && t.setData({
                        LoadMoreTest: "加载更多"
                    }), e.data.recommend.goo = !0, t.setData({
                        cartInfo: e.data.member_cart,
                        page: 1,
                        isLoadMore: !0
                    }), e.data.goods_list.data ? t.setData({
                        foodInfo: e.data.goods_list.data
                    }) : t.setData({
                        foodInfo: []
                    }), e.data.set.cat_brand && e.data.set.cat_brand.length > 0 && t.setData({
                        brandShow: e.data.set.cat_brand
                    }), e.data.set.cat_class && e.data.set.cat_class.length > 0 && (t.setData({
                        categoryShow: e.data.set.cat_class
                    }), "0" != t.data.categoryShow && t.data.onelist.length > 0 && (console.log("sssssss初始化的时候"), 
                    t.tabsaData(0, t.data.onelist[0]))), "0" == t.data.categoryShow && (console.log("第一次进入的是推荐分类页面"), 
                    t.setData({
                        "contentlist.recommend": e.data.recommend,
                        "contentlist.set": e.data.set,
                        "contentlist.member_cart": e.data.member_cart,
                        list: t.data.contentlist,
                        ADImg: e.data.set.cat_adv_img,
                        ADUrl: e.data.set.cat_adv_url,
                        small_cat_adv_url: e.data.set.small_cat_adv_url
                    }), t.setCatagory(t.data.contentlist)); else {
                        t.setData({
                            isLoadMore: !1
                        });
                        var i = {
                            goo: !0
                        };
                        i.dataK = e.data.recommend, i.tjfl = !0, i.set = e.data.set, e.data.set.cat_brand && e.data.set.cat_brand.length > 0 && t.setData({
                            brandShow: e.data.set.cat_brand
                        }), e.data.set.cat_class && e.data.set.cat_class.length > 0 && (t.setData({
                            categoryShow: e.data.set.cat_class
                        }), "0" != t.data.categoryShow && t.data.onelist.length > 0 && t.tabsaData(0, t.data.onelist[0])), 
                        "0" == t.data.categoryShow && t.setData({
                            contentlist_one: i,
                            list: i
                        });
                    }
                } else wx.hideLoading(), t.setData({
                    err: !0,
                    showCate: !0
                }), console.log(e.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    updateCategoryData: function(t) {
        var a = t.detail;
        this.setData({
            tiktok_list: a.list,
            page: a.page,
            total_page: a.total_page,
            "tiktok_details.order_type": a.order_type,
            "tiktok_details.search_type": a.search_type
        });
    },
    getMoreData: function() {
        var t = this;
        if (t.data.page >= t.data.total_page) return t.setData({
            LoadMoreTest: "没有更多"
        }), void t.setData({
            isLoadMore: !1
        });
        t.setData({
            isLoadMore: !0
        });
        var e = t.data.page;
        if (e += 1, t.setData({
            page: e
        }), "tiktok" != this.data.current_goods_key) {
            var s, o = g.getNetAddresss(a.goods);
            (this.data.searchScreen.top || this.data.searchScreen.mini) && (s = this.data.searchScreen.mini ? "".concat(this.data.searchScreen.mini).concat(this.data.searchScreen.top ? "," + this.data.searchScreen.top : this.data.searchScreen.top ? this.data.searchScreen.top : "") : this.data.searchScreen.top);
            var i = {
                goods_page: t.data.page,
                category_id: t.data.activatId,
                order_field: this.data.searchScreen.order_field || "",
                order_by: this.data.searchScreen.order_by || "",
                "search[brand_id]": this.data.searchScreen.brandId || "",
                "search[product_attr]": this.data.searchScreen.attrstr || "",
                "search[filtering]": this.data.searchScreen.filterId || "",
                "search[price_range]": s || ""
            };
            g._getNetWork({
                url: o,
                data: i,
                success: function(a) {
                    var e = a.data;
                    if (t.setData({
                        isLoadMore: !0
                    }), 1 != e.result) {
                        var s = t.data.page;
                        return s -= 1, void t.setData({
                            page: s,
                            isLoadMore: !1
                        });
                    }
                    var o = t.data.foodInfo;
                    o = o.concat(e.data.data), t.setData({
                        foodInfo: o
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        } else this.getTikTokGoods();
    },
    getMoreData02: function(t) {
        var e = this;
        if (1 == t && e.data.page >= e.data.total_page) e.setData({
            LoadMoreTest: "没有更多",
            isLoadMore: !1
        }); else if (0 == t && e.data.isCategoryPage >= e.data.isCategory_total_page) e.setData({
            isCategoryMore: !1
        }); else {
            e.setData({
                isLoadMore: !1
            });
            var s = 1 == t ? e.data.page : e.data.isCategoryPage;
            s += 1, 1 == t ? e.setData({
                page: s
            }) : e.setData({
                isCategoryPage: s
            });
            var o = g.getNetAddresss(a.children);
            console.log("activeApi.children333");
            var i = {
                page: 1 == t ? e.data.page : e.data.isCategoryPage,
                parent_id: e.data.parent_id,
                as_id: e.data.zoneId
            };
            g._getNetWork({
                url: o,
                data: i,
                success: function(a) {
                    var o = a.data;
                    if (1 != o.result) {
                        var i = 1 == t ? e.data.page : e.data.isCategoryPage;
                        return i -= 1, void (1 == t ? e.setData({
                            page: i,
                            isLoadMore: !1
                        }) : e.setData({
                            isCategoryPage: s
                        }));
                    }
                    if (1 == t) {
                        var r = e.data.contentlist_one.data.concat(o.data.data);
                        e.setData({
                            "contentlist_one.data": r,
                            isLoadMore: !0
                        });
                    } else {
                        var d = e.data.list.recommend.concat(o.data.data);
                        e.setData({
                            "list.recommend": d,
                            isCategoryMore: !(e.data.isCategoryPage >= e.data.isCategory_total_page)
                        });
                    }
                },
                fail: function(t) {
                    console.log("error", t);
                }
            });
        }
    },
    numberLeft: function(t) {
        var a = t.target.dataset.id || t.currentTarget.dataset.id, e = this.data.goodsCartsTotal;
        Number(e), e = Number(e[a].total) - 1, this.data.goodsCartsTotal[a].total = e, this.data.goodsCartsTotal[a].total <= 0 ? this.destroyData(this.data.goodsCarts[a].id) : this.changeCount(this.data.goodsCarts[a].id, this.data.goodsCartsTotal[a].total);
    },
    numberRight: function(t) {
        var a = this, e = t.target.dataset.id || t.currentTarget.dataset.id, s = t.target.dataset.stock || t.currentTarget.dataset.stock, o = t.target.dataset.good || t.currentTarget.dataset.good;
        if ("101" != o.plugin_id) {
            if (o.vip_level_status && 1 == o.vip_level_status.status) return wx.showToast({
                title: o.vip_level_status.tips,
                icon: "none",
                duration: 2e3
            }), !1;
            if (0 != s) {
                if (!g._isTextEmpty(this.data.goodsCartsTotal[e])) {
                    if (this.data.goodsCartsTotal[e].total >= s) return console.log("数量超出范围"), void wx.showToast({
                        title: "库存不足",
                        icon: "none"
                    });
                    var i = this.data.goodsCartsTotal;
                    i = Number(i[e].total) + 1, this.data.goodsCartsTotal[e].total = i;
                }
                var r = {
                    goods_id: e,
                    total: 1
                }, d = g.getNetAddresss("member.member-cart.store");
                g._getNetWork({
                    url: d,
                    data: r,
                    success: function(t) {
                        var e = t.data;
                        1 == e.result ? (g.globalData.cart_num = g.globalData.cart_num + 1, wx.showToast({
                            title: e.msg,
                            icon: "none"
                        }), a.updateData()) : wx.showToast({
                            title: e.msg,
                            icon: "none"
                        });
                    }
                });
            } else wx.showToast({
                title: "库存为零",
                icon: "none"
            });
        } else wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + o.id
        });
    },
    changeCount: function(t, a) {
        var e = this;
        if (a <= 0) this.destroyData(t); else {
            var s = {
                id: t,
                num: a
            }, o = g.getNetAddresss("member.member-cart.updateNumV2");
            g._getNetWork({
                url: o,
                data: s,
                success: function(t) {
                    var a = t.data;
                    1 == a.result ? (wx.showToast({
                        title: a.msg,
                        icon: "none"
                    }), e.updateData()) : (wx.showToast({
                        title: a.msg,
                        icon: "none"
                    }), e.setData({
                        "goodsCartsTotal[_id].total": 1
                    }));
                }
            });
        }
    },
    changeAddCount: function(t) {
        var a = this, e = t.target.dataset.id || t.currentTarget.dataset.id, s = t.target.dataset.num || t.currentTarget.dataset.num, o = t.target.dataset.i || t.currentTarget.dataset.i;
        if (o = Number(o), s <= 0) this.destroyData(e); else {
            var i = {
                id: e,
                num: s
            }, r = g.getNetAddresss("member.member-cart.updateNumV2");
            g._getNetWork({
                url: r,
                data: i,
                success: function(t) {
                    var e = t.data;
                    if (1 == e.result) {
                        if (wx.showToast({
                            title: e.msg,
                            icon: "none"
                        }), !g._isTextEmpty(o)) {
                            var s = a.data.popNum;
                            switch (o) {
                              case -1:
                                s -= 1, a.setData({
                                    popNum: s
                                });
                                break;

                              case 1:
                                s += 1, a.setData({
                                    popNum: s
                                });
                                break;

                              default:
                                console.log("error");
                            }
                        }
                        a.updateData();
                    } else wx.showToast({
                        title: e.msg,
                        icon: "none"
                    }), a.setData({
                        "goodsCartsTotal[_id].total": 1
                    });
                }
            });
        }
    },
    updateData: function() {
        var t = this, a = g.getNetAddresss("member.member-cart.index");
        g._getNetWork({
            url: a,
            success: function(a) {
                var e = a.data;
                1 == e.result ? t.getCart(e.data) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            }
        });
    },
    destroyData: function(t) {
        var a = this, e = g.getNetAddresss("member.member-cart.destroy"), s = {
            ids: t
        };
        g._getNetWork({
            url: e,
            data: s,
            success: function(t) {
                var e = t.data;
                1 == e.result ? (wx.showToast({
                    title: e.msg,
                    icon: "none"
                }), g.globalData.cart_num = g.globalData.cart_num - 1, a.updateData(), a.setData({
                    show2: !1
                })) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            }
        });
    },
    chooseSecondary: function(t) {
        var a = t.target.dataset.item || t.currentTarget.dataset.item;
        if (this.data.isRecommend || this.setData({
            ADImg: a.adv_img,
            ADUrl: a.adv_url
        }), this.setData({
            secondaryId: a.id
        }), g._isTextEmpty(a.has_many_children)) this.setData({
            threeInfo: []
        }), this.getData(a.id); else {
            var e = [ {
                name: "全部",
                id: a.id
            } ], s = [].concat(e, r(a.has_many_children));
            console.log("SecondaryName================", a), this.setData({
                SecondaryName: a.name,
                threeInfo: s,
                activatId: a.id,
                threeId: a.id
            }), console.log("sssssss", this.data.threeInfo), this.getData(a.id);
        }
    },
    koosThree: function(t) {
        this.setData({
            threeId: t
        }), this.getData(t);
    },
    chooseThree: function(t) {
        var a = t.target.dataset.id || t.currentTarget.dataset.id;
        this.setData({
            threeId: a
        }), this.getData(a);
    },
    cloneCollapse: function() {
        this.setData({
            activeName: []
        });
    },
    getData: function(t) {
        var e, s = this;
        (this.data.searchScreen.top || this.data.searchScreen.mini) && (e = this.data.searchScreen.mini ? "".concat(this.data.searchScreen.mini).concat(this.data.searchScreen.top ? "," + this.data.searchScreen.top : this.data.searchScreen.top ? this.data.searchScreen.top : "") : this.data.searchScreen.top), 
        console.log(this.data.searchScreen, "ddddddddddd");
        var o = {
            category_id: t,
            goods_page: 1,
            order_field: this.data.searchScreen.order_field || "",
            order_by: this.data.searchScreen.order_by || "",
            "search[brand_id]": this.data.searchScreen.brandId || "",
            "search[product_attr]": this.data.searchScreen.attrstr || "",
            "search[filtering]": this.data.searchScreen.filterId || "",
            "search[price_range]": e || ""
        };
        this.setData({
            activatId: t,
            activeName: "",
            foodInfo: []
        });
        var i = g.getNetAddresss(a.goods);
        g._getNetWork({
            url: i,
            data: o,
            success: function(t) {
                var a = t.data;
                1 == a.result ? (s.setData({
                    page: 1,
                    isLoadMore: !0,
                    total_page: a.data.last_page,
                    foodInfo: a.data.data
                }), 1 == a.data.last_page ? s.setData({
                    LoadMoreTest: "没有更多"
                }) : s.setData({
                    LoadMoreTest: "加载更多"
                }), s.data.total_page || s.setData({
                    total_page: 0
                })) : (wx.showToast({
                    title: a.msg,
                    icon: "none"
                }), console.log(a.msg));
            }
        });
    },
    getCart: function(t) {
        var a = this;
        this.setData({
            carts: t,
            goodsCarts: [],
            cartIDs: []
        });
        var e = {};
        this.data.carts.forEach(function(s) {
            e[s.goods_id] = s, t && t.id == s.goods_id && (t.buyNum = s.total), s.goods_id == a.data.goodsInfo.id && s.option_id == _ && a.setData({
                popNum: s.total,
                popCard: s
            }), a.data.cartIDs.push(s.id);
        }), this.setData({
            goodsCarts: e
        });
        var s = this.calculateTotal(this.data.carts);
        this.setData({
            goodsCartsTotal: s
        });
    },
    changeblur: function(t) {
        var a = t.detail.value, e = t.target.dataset.id || t.currentTarget.dataset.id;
        if (a > (t.target.dataset.stock || t.currentTarget.dataset.stock)) {
            var s = this.data.goodsCartsTotal;
            return wx.showToast({
                title: "商品库存不足",
                icon: "none"
            }), void this.setData({
                goodsCartsTotal: s
            });
        }
        this.changeCount(e, a);
    },
    calculateTotal: function(t) {
        var a = [], e = {}, s = {};
        for (var o in t) {
            var i = t[o].goods_id;
            e[i] ? e[i].total = e[i].total + t[o].total : (e[i] = {}, e[i].goods_id = t[o].goods_id, 
            e[i].total = t[o].total);
        }
        for (var r in e) a.push(e[r]);
        return a.forEach(function(t) {
            s[t.goods_id] = t;
        }), s;
    },
    setCatagory: function(t) {
        if (g._isTextEmpty(t.recommend)) this.setData({
            titleInfo: [],
            showTitle: [],
            secondaryId: [],
            threeInfo: [],
            threeId: null
        }); else {
            var a = t.recommend;
            this.data.active2 || "05" == this.data.category_template || a.unshift({
                name: "全部",
                id: this.data.activatId,
                adv_img: this.data.state.adv_img,
                adv_url: this.data.state.adv_url
            }), this.setData({
                titleInfo: a,
                "list.recommend": a,
                "contentlist.recommend": a,
                secondaryId: t.recommend[0].id
            }), "3" != t.set.cat_level || g._isTextEmpty(t.recommend[0].has_many_children) ? this.setData({
                threeInfo: [],
                threeId: null,
                activatId: this.data.secondaryId
            }) : (this.setData({
                threeInfo: t.recommend[0].has_many_children,
                threeId: t.recommend[0].has_many_children[0].id,
                activatId: this.data.threeId,
                ADImg: t.recommend[0].adv_img,
                ADUrl: t.recommend[0].adv_url
            }), this.data.threeId && "05" == this.data.category_template && this.getData(this.data.threeId)), 
            this.setData({
                activeName: ""
            }), this.getCart(t.member_cart);
        }
    },
    addGood: function(t) {
        var a = t.target.dataset.item || t.currentTarget.dataset.item;
        if ("101" != a.plugin_id) {
            if (a.vip_level_status && 1 == a.vip_level_status.status) return wx.showToast({
                title: a.vip_level_status.tips,
                icon: "none",
                duration: 2e3
            }), !1;
            this.setData({
                show2: !0,
                goodsInfo: a
            }), this.initPopView();
        } else wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + a.id
        });
    },
    initPopView: function() {
        if (_ = "", h = [], this.setData({
            specid: "",
            popNum: 0
        }), 1 == this.data.goodsInfo.has_option) {
            if (this.isShowMultiSpecsMemPrice(), this.setData({
                popTitle: this.data.goodsInfo.title,
                popThumb: this.data.goodsInfo.thumb,
                popStock: this.data.goodsInfo.stock,
                popCard: {}
            }), !this.data.specid.length) {
                var t = this.data.goodsInfo.min_price + "-" + this.data.goodsInfo.max_price;
                this.data.goodsInfo.point_goods && (t = this.data.goodsInfo.point_goods.min_point + "-" + this.data.goodsInfo.point_goods.max_point), 
                this.setData({
                    popPrice: t
                });
            }
            var a;
            this.setData({
                goodsDescription: "请选择"
            });
            for (var e = 0; e < this.data.goodsInfo.has_many_specs.length; e++) a = this.data.goodsDescription, 
            a += "" + this.data.goodsInfo.has_many_specs[e].title;
            if (this.setData({
                goodsDescription: a
            }), !this.data.optionsId) for (var s = 0; s < this.data.goodsInfo.has_many_specs.length; s++) if (this.data.goodsInfo.goods_option_ids && this.data.goodsInfo.goods_option_ids.length >= 0) for (var o = 0; o < this.data.goodsInfo.has_many_specs[s].has_many_specs_item.length; o++) this.data.goodsInfo.has_many_specs[s].has_many_specs_item[o].id == Number(this.data.goodsInfo.goods_option_ids[s]) && this.selectSpecs(this.data.goodsInfo.has_many_specs[s].has_many_specs_item[o], "first", s); else this.selectSpecs(this.data.goodsInfo.has_many_specs[s].has_many_specs_item[0], "first", s);
        } else this.setData({
            goodsDescription: "",
            optionsMaxCount: this.data.goodsInfo.stock
        });
    },
    isShowMultiSpecsMemPrice: function() {
        this.data.goodsInfo.is_open_micro && 1 == Number(this.data.goodsInfo.is_open_micro) && 1 == this.data.goodsInfo.has_option ? this.setData({
            isMultiSpecs: !0
        }) : this.setData({
            isMultiSpecs: !1
        });
    },
    selectSpecs: function(t, a, e) {
        var s = {}, o = 0;
        "first" == a ? (s = t, o = t.id) : (s = t.target.dataset.item || t.currentTarget.dataset.item, 
        o = t.target.dataset.id || t.currentTarget.dataset.id), this.manageSpecs(s), this.setGoodsSpecs(s), 
        this.setGoodsSpecsChangeInfo(o), this.getMaxCount();
    },
    getMaxCount: function() {
        h.length == this.data.goodsInfo.has_many_specs.length && (0 == p && this.setData({
            popNum: 0
        }), this.data.popNum > p && this.setData({
            popNum: p
        }));
    },
    setGoodsSpecsChangeInfo: function(t) {
        var a = "";
        if (h.sort(function(t, a) {
            return t.id - a.id;
        }), h.length === this.data.goodsInfo.has_many_specs.length) {
            for (var e = "", s = 0; s < h.length; s++) e += h[s].id + "_";
            e = e.substring(0, e.length - 1), this.setData({
                specid: e
            });
            for (var o = 0; o < this.data.goodsInfo.has_many_options.length; o++) if (e === this.setGoodsSpecsBySort(this.data.goodsInfo.has_many_options[o].specs)) {
                a = this.data.goodsInfo.point_goods ? this.data.goodsInfo.point_goods.point_option[o].goods_point : this.data.goodsInfo.has_many_options[o].product_price, 
                this.setData({
                    popPrice: a
                });
                var i = g._isTextEmpty(this.data.goodsInfo.has_many_options[o].thumb) ? this.data.goodsInfo.thumb : this.data.goodsInfo.has_many_options[o].thumb;
                this.setData({
                    popThumb: i,
                    popStock: this.data.goodsInfo.has_many_options[o].stock
                }), _ = this.data.goodsInfo.has_many_options[o].id, (p = this.data.goodsInfo.has_many_options[o].stock) > 0 && this.setData({
                    popNum: 0
                }), this.data.isMultiSpecs && this.getMemberPrice(_);
                break;
            }
            for (var r = 0; r < this.data.carts.length; r++) {
                if (this.data.carts[r].goods_id == this.data.goodsInfo.id && this.data.carts[r].option_id == _) {
                    this.setData({
                        popNum: this.data.carts[r].total,
                        popCard: this.data.carts[r]
                    });
                    break;
                }
                this.setData({
                    popNum: 0,
                    popCard: {}
                });
            }
        } else {
            for (var d = "", n = 0; n < h.length; n++) d += h[n].id + "_";
            this.setData({
                specid: d
            });
        }
    },
    setGoodsSpecsBySort: function(t) {
        var a = t.split("_");
        a.sort(function(t, a) {
            return t - a;
        });
        for (var e = "", s = 0; s < a.length; s++) e += a[s] + "_";
        return e = e.substring(0, e.length - 1);
    },
    manageSpecs: function(t) {
        var a = {};
        if (a.id = t.id, a.specid = t.specid, a.title = t.title, h.length > 0) {
            for (var e = 0; e < h.length; e++) h[e].specid == a.specid && h.splice(e, 1);
            h.push(a);
        } else h.push(a);
        if (h.length == this.data.goodsInfo.has_many_specs.length) {
            for (var s = [], o = 0; o < this.data.goodsInfo.has_many_specs.length; o++) for (var i = 0; i < h.length; i++) if (this.data.goodsInfo.has_many_specs[o].id == h[i].specid) {
                s.push(h[i]);
                break;
            }
            h = s;
        }
        this.setGoodsDescription();
    },
    setGoodsDescription: function() {
        var t = "";
        if (h.length == this.data.goodsInfo.has_many_specs.length) {
            t = "已选择 ";
            for (var a = 0; a < h.length; a++) t += h[a].title + " ";
            this.setData({
                goodsDescription: t
            });
        } else {
            t = "请选择 ";
            for (var e = 0; e < this.data.goodsInfo.has_many_specs.length; e++) for (var s = 0; s < h.length; s++) if (this.data.goodsInfo.has_many_specs[e].id != h[s].specid) {
                t += this.data.goodsInfo.has_many_specs[e].title + " ";
                break;
            }
            this.setData({
                goodsDescription: t
            });
        }
    },
    setGoodsSpecs: function(t) {
        for (var a = 0; a < this.data.goodsInfo.has_many_specs.length; a++) t.specid != this.data.goodsInfo.has_many_specs[a].id && this.setGoodsSpecsStatus(this.data.goodsInfo.has_many_specs[a].has_many_specs_item, t.id);
    },
    setGoodsSpecsStatus: function(t, a) {
        for (var e = [], s = 0; s < this.data.goodsInfo.has_many_options.length; s++) for (var o = this.data.goodsInfo.has_many_options[s].specs.split("_"), i = 0; i < o.length; i++) o[i] == a && e.push(this.data.goodsInfo.has_many_options[s]);
        for (var r = 0; r < e.length; r++) for (var d = e[r].specs.split("_"), n = 0; n < d.length; n++) if (d[n] != a && 0 == e[r].stock) for (var c = 0; c < t.length; c++) d[n] == t[c].id && (t[c].c = !0); else if (d[n] != a && e[r].stock > 0) for (var l = 0; l < t.length; l++) d[n] == t[l].id && (t[l].c = !1);
    },
    submitAction: function() {
        var t = this;
        if (h.length < this.data.goodsInfo.has_many_specs.length) return this.setData({
            show2: !1
        }), void wx.showToast({
            title: this.data.goodsDescription,
            icon: "none"
        });
        var a = g.getNetAddresss("member.member-cart.store"), e = {
            goods_id: this.data.goodsInfo.id,
            total: 1,
            option_id: _
        };
        g._getNetWork({
            url: a,
            data: e,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (g.globalData.cart_num = e.data.cart_num, wx.showToast({
                    title: e.msg,
                    icon: "none"
                }), t.updateData(), t.setData({
                    popNum: t.data.popNum + 1
                })) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    close: function() {
        this.setData({
            show2: !1
        });
    },
    gotosearch: function() {
        var t = "/packageB/member/category/search_v2/search_v2";
        "05" != this.data.category_template ? "04" != this.data.category_template || "tiktok" != this.data.current_goods_key ? (this.options.tmpl && "dy" == this.options.tmpl && (t += "?tmpl=dy"), 
        wx.navigateTo({
            url: t
        })) : wx.navigateTo({
            url: "/packageF/cps/search/search"
        }) : wx.navigateTo({
            url: "/packageI/searchPage/searchPage"
        });
    },
    gotoGoods: function(t) {
        var a = t.target.dataset.id || t.currentTarget.dataset.id, e = t.currentTarget.dataset.good;
        console.log(e), e.category_option_id ? wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + a + "&coid=" + e.category_option_id
        }) : wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + a
        });
    },
    getNowPackageDeliver: function() {
        var t = this;
        return n(d.default.mark(function e() {
            var s;
            return d.default.wrap(function(e) {
                for (;;) switch (e.prev = e.next) {
                  case 0:
                    a = {
                        home: "plugin.supplier.frontend.category.category-home",
                        children: "plugin.supplier.frontend.category.get-children-category",
                        goods: "plugin.supplier.frontend.category.get-goods-list-by-category-id"
                    }, s = null;
                    try {
                        s = wx.getStorageSync("deliverId");
                    } catch (t) {}
                    if (!s) {
                        e.next = 8;
                        break;
                    }
                    return t.data.deliverId && t.data.deliverId != s && (t.data.deliverId = s, t.getCategoryNew()), 
                    e.abrupt("return", !0);

                  case 8:
                    if (t.options.dyID) {
                        e.next = 11;
                        break;
                    }
                    return e.next = 11, t._asyncLocation();

                  case 11:
                    return wx.showLoading({
                        title: "加载中",
                        mask: !0
                    }), e.abrupt("return", new Promise(function(a, e) {
                        var s = {};
                        t.data.point && t.data.point.lng && (s = {
                            lng: t.data.point.lng || "",
                            lat: t.data.point.lat || ""
                        }), t.options.dyID && (s.deliver_id = t.options.dyID);
                        var o = g.getNetAddresss("plugin.package-deliver.frontend.decorate-deliver.getNowPackageDeliver");
                        g._postNetWork({
                            url: o,
                            data: s,
                            success: function(s) {
                                wx.hideLoading();
                                var o = s.data;
                                1 == o.result ? (t.data.deliverId = o.data.id, wx.setStorageSync("deliverId", o.data.id), 
                                a()) : (wx.showToast({
                                    title: o.msg,
                                    duration: 1e3,
                                    icon: "none"
                                }), e());
                            },
                            fail: function(t) {
                                wx.hideLoading(), console.log(t.msg);
                            }
                        });
                    }));

                  case 13:
                  case "end":
                    return e.stop();
                }
            }, e);
        }))();
    },
    _asyncLocation: function() {
        var t = this;
        return new Promise(function(a, e) {
            t._getLocation(function(e, s) {
                var o = g.qqMapTransBMap(parseFloat(s.lng), parseFloat(s.lat));
                t.data.point = o, a();
            });
        });
    },
    getMemberPrice: function(t) {
        var a = this;
        if (t) {
            var e = 0;
            this.setData({
                specsVIPPrc: e
            });
            var s = g.getNetAddresss("goods.other-info.option-vpi-price");
            s += "&option_id=" + t, g._getNetWork({
                showToastIn: !1,
                url: s,
                success: function(t) {
                    var s = t.data;
                    e = 1 == s.result && s.data.vip_price || null, a.setData({
                        specsVIPPrc: e
                    });
                },
                fail: function(t) {
                    e = null, this.setData({
                        specsVIPPrc: e
                    });
                }
            });
        }
    },
    tapUrl: function(t) {
        var a = t.currentTarget.dataset.item;
        try {
            wx.navigateTo({
                url: a.mini_url,
                fail: function(t) {
                    wx.switchTab({
                        url: a.mini_url
                    });
                }
            });
        } catch (t) {
            wx.switchTab({
                url: a.mini_url
            });
        }
    },
    getwebdesImg: function() {
        var t = this, a = g.getNetAddresss("plugin.web-design.frontend.carousel.index");
        g._getNetWork({
            url: a,
            success: function(a) {
                var e = a.data;
                t.setData({
                    webdesImage: e.data
                });
            },
            fail: function(t) {
                wx.showToast({
                    title: t.msg,
                    icon: "none",
                    duration: 1e3
                });
            }
        });
    },
    showbox: function() {
        this.setData({
            showGoodScreen: !this.data.showGoodScreen
        });
    },
    sortOut: function(t) {
        this.setData(c({
            showGoodScreen: !1
        }, "searchScreen.order_field", t.detail.order_field)), this.data.searchScreen.order_by = t.detail.order_by, 
        this.getData(this.data.activatId);
    },
    confirmGoodScreen: function(t) {
        var a = t.detail;
        this.setData({
            showGoodScreen: !1,
            searchScreen: a
        }), this.getData(this.data.activatId);
    },
    cloneGoodScreen: function() {
        this.setData({
            showGoodScreen: !1
        });
    }
});